Skip to content

feat: add log file support and rendering optimisations#14

Closed
neilmartin83 wants to merge 13 commits intomacadmins:mainfrom
neilmartin83:nm-log-support-speed-optimisations
Closed

feat: add log file support and rendering optimisations#14
neilmartin83 wants to merge 13 commits intomacadmins:mainfrom
neilmartin83:nm-log-support-speed-optimisations

Conversation

@neilmartin83
Copy link
Copy Markdown
Contributor

Summary

Adds QuickLook preview support for log files (.log, .out, .err) with
heuristic-based syntax highlighting. Since log files have no consistent format,
the tokenizer uses pattern matching to colorize the most common elements that
make logs scannable at a glance.

Also speeds up rendering of large files.

image image image image

What's highlighted

Element Examples Color
Timestamps 2025-09-16 06:20:56 +0100, Mar 28 14:05:33, Apache CLF Muted (italic)
FATAL / CRITICAL / ALERT FATAL, CRITICAL: Bold red
ERROR ERROR, ERROR: Bold red
WARNING WARN, WARNING: Orange
INFO / NOTICE INFO, INFO: Blue
DEBUG / TRACE DEBUG, VERBOSE Muted (italic)
IPv4 addresses 192.168.1.100 Green
HTTP methods GET, POST, DELETE Purple
HTTP status codes 200 (green), 404 (orange), 500 (red) By class
Double-quoted strings "disk space low" String color
File paths /usr/local/etc/config.yaml Variable color
Numbers with units 512MB, 30s, 94% Green

Single quotes are intentionally not treated as string delimiters — apostrophes
in natural log text (JWT's, doesn't) are far too common.

Performance

Log files can be large (2MB+), so three optimizations were made:

  • Line-by-line tokenization for .log — avoids O(n²) regex scanning over
    the entire file by processing each line independently
  • escapeHTML rewritten as a single-pass character scan (was 4 chained
    replacingOccurrences calls, benefiting all formats)
  • renderTokens uses a pre-allocated buffer instead of map + joined
  • Truncation at ~500KB for all formats, with a
    "⋯ Preview truncated (X of Y lines shown)" notice

Files changed (8 files, +306 −23)

  • Shared/SyntaxHighlighter.swift.log format, tokenizer, perf improvements, truncation
  • PiquePreview/Info.plist — UTI, QLSupportedContentTypes, QLFileExtensions
  • PiquePreview/PreviewProvider.swift — format name mapping
  • Pique/Info.plist — UTI declaration
  • Pique/ContentView.swift — Log badge
  • Pique/SettingsView.swift — Log in appearance settings
  • PiqueTests/FileFormatTests.swift — extension mapping + case insensitivity
  • PiqueTests/HighlightIntegrationTests.swift — 15 new tests

Tests

137 total, 0 failures. New tests cover:

  • Severity levels (all tiers, with and without colon)
  • Timestamps (ISO 8601, syslog)
  • IPv4 addresses, HTTP methods, status code coloring by class
  • File paths, double-quoted strings
  • Apostrophe safety (JWT's not treated as string)
  • Multi-line preservation
  • Truncation for large inputs
  • No truncation for small inputs
  • Case-insensitive extension mapping (.LOG)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds QuickLook preview support for log-like files and introduces rendering optimizations to keep previews responsive on large inputs.

Changes:

  • Add .log/.out/.err as a supported FileFormat with a heuristic, line-by-line tokenizer.
  • Add large-input truncation and optimize HTML rendering (escapeHTML, renderTokens) to reduce allocation overhead.
  • Register log UTIs / file extensions for the app + preview extension, and add UI + test coverage for the new format.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
Shared/SyntaxHighlighter.swift Adds log tokenizer; adds truncation + rendering performance changes.
PiquePreview/Info.plist Registers io.macadmins.pique.log and adds log extensions/UTIs to QuickLook supported types.
PiquePreview/PreviewProvider.swift Maps log-like extensions to the “Log” appearance group name.
Pique/Info.plist Declares the log UTI for the main app bundle.
Pique/ContentView.swift Adds “Log” to the supported format badges.
Pique/SettingsView.swift Adds “Log” to appearance override settings.
PiqueTests/FileFormatTests.swift Tests .log/.out/.err mapping + case-insensitivity.
PiqueTests/HighlightIntegrationTests.swift Adds integration tests for log highlighting + truncation behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Shared/SyntaxHighlighter.swift Outdated
Comment thread Shared/SyntaxHighlighter.swift Outdated
Comment thread Shared/SyntaxHighlighter.swift
Comment thread Shared/SyntaxHighlighter.swift Outdated
Comment thread Shared/SyntaxHighlighter.swift Outdated
Comment thread Shared/SyntaxHighlighter.swift Outdated
@neilmartin83
Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread

neilmartin83 and others added 2 commits April 18, 2026 14:24
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Update log token classes and rendering plus add robust preview truncation. Tests were updated to expect new log-specific CSS classes (logError, logWarn, logInfo, logDebug, logTimestamp). SyntaxHighlighter was refactored to: count lines efficiently, truncate at the last line boundary within the preview limit, append a styled truncation notice, and apply truncation to special-format renderers (mobileconfig/JSON profiles). The token pipeline was unified to renderTokens in the switch, new Token.Kind entries for log categories were added, and the log tokenizer/status-code mapping and color palettes (dark/light) were adjusted accordingly.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds .log QuickLook preview support and improves rendering performance for large files by introducing truncation and faster HTML/token rendering in the shared highlighter.

Changes:

  • Add .log (.log, .out, .err) file format with heuristic, line-by-line tokenization and new severity/timestamp token kinds + CSS.
  • Optimize rendering performance (escapeHTML single-pass, renderTokens preallocated buffer) and truncate large previews (~500KB) with a truncation notice.
  • Register log UTIs / extensions in app + QuickLook extension and expose “Log” in UI/settings; add tests for format mapping + log highlighting.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Shared/SyntaxHighlighter.swift Adds .log format, log tokenizer + new token kinds/styles, rendering optimizations, and truncation logic/notice.
PiquePreview/Info.plist Declares log UTI and registers it (and related types/extensions) for QuickLook preview support.
PiquePreview/PreviewProvider.swift Maps .log/.out/.err extensions to the “Log” appearance group name.
Pique/Info.plist Declares the log UTI for the main app.
Pique/ContentView.swift Adds a “Log” badge to the supported formats list shown in the app UI.
Pique/SettingsView.swift Adds “Log” to appearance override settings groups.
PiqueTests/FileFormatTests.swift Tests extension-to-FileFormat mapping for log-related extensions (including case-insensitivity).
PiqueTests/HighlightIntegrationTests.swift Adds integration tests for log highlighting and truncation behavior (currently focused on .log).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Shared/SyntaxHighlighter.swift Outdated
Comment thread Shared/SyntaxHighlighter.swift Outdated
Comment thread PiqueTests/HighlightIntegrationTests.swift Outdated
Comment thread Shared/SyntaxHighlighter.swift Outdated
@neilmartin83
Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds QuickLook preview support for log-like files (.log, .out, .err) with heuristic syntax highlighting, and introduces rendering optimizations intended to improve performance on large inputs (including a preview truncation feature).

Changes:

  • Add a .log file format with a heuristic, line-by-line tokenizer and dedicated token kinds/styles.
  • Add UTType/QuickLook registration and format-name mapping for log files across the app and preview extension.
  • Optimize HTML generation (escapeHTML, renderTokens) and add large-input truncation with an appended notice.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Shared/SyntaxHighlighter.swift Adds .log support, new token kinds/CSS, HTML rendering optimizations, and truncation/notice logic.
PiquePreview/Info.plist Registers a log UTType and adds supported content types/extensions for QuickLook.
PiquePreview/PreviewProvider.swift Maps log extensions to the “Log” appearance group name.
Pique/Info.plist Declares the log UTType for the host app.
Pique/ContentView.swift Adds a “Log” badge to the marketing/overview UI.
Pique/SettingsView.swift Adds “Log” to appearance override settings.
PiqueTests/FileFormatTests.swift Adds extension mapping tests for .log/.out/.err (including case-insensitivity).
PiqueTests/HighlightIntegrationTests.swift Adds integration tests for log highlighting and truncation notice behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Shared/SyntaxHighlighter.swift Outdated
Comment thread Shared/SyntaxHighlighter.swift Outdated
Comment thread Shared/SyntaxHighlighter.swift Outdated
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds QuickLook preview/highlighting support for log-like plain text files and improves rendering performance for large previews across formats.

Changes:

  • Introduces .log as a supported FileFormat (.log, .out, .err) with heuristic, line-by-line tokenization and dedicated log token kinds/CSS.
  • Adds preview truncation (~512k chars) with an in-preview “Preview truncated …” notice, plus rendering/escaping optimizations.
  • Registers log UTIs / extensions for QuickLook and exposes “Log” in the app UI + appearance settings; adds/extends tests.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Shared/SyntaxHighlighter.swift Adds .log support, truncation + notice insertion, and rendering/escaping perf optimizations
PiquePreview/Info.plist Registers log UTI + adds supported content types/extensions for QuickLook
PiquePreview/PreviewProvider.swift Maps .log/.out/.err to a user-facing “Log” format name
Pique/Info.plist Declares exported UTI for log files
Pique/ContentView.swift Adds “Log” to the format badge list
Pique/SettingsView.swift Adds “Log” to appearance override options
PiqueTests/FileFormatTests.swift Verifies .log/.out/.err mapping + case-insensitive extension handling
PiqueTests/HighlightIntegrationTests.swift Adds integration tests for log highlighting + truncation behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Shared/SyntaxHighlighter.swift
Comment thread PiqueTests/HighlightIntegrationTests.swift Outdated
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds QuickLook preview support for common log-file extensions with heuristic syntax highlighting, and introduces rendering optimizations to keep large-file previews responsive across formats.

Changes:

  • Add .log file format detection (.log, .out, .err) and a heuristic, line-by-line log tokenizer with dedicated token kinds + CSS.
  • Improve HTML rendering performance (escapeHTML single-pass, renderTokens buffer preallocation) and add preview truncation with an in-preview notice.
  • Register log UTIs / QuickLook supported types and extend UI + test coverage for the new format and truncation behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Shared/SyntaxHighlighter.swift Adds .log highlighting, truncation logic + notice insertion, and rendering performance improvements.
PiquePreview/Info.plist Declares log UTI and adds log types/extensions to QuickLook supported content.
PiquePreview/PreviewProvider.swift Maps log extensions to a user-facing “Log” format name.
Pique/Info.plist Declares the log UTI in the main app.
Pique/ContentView.swift Adds “Log” to the format badge list.
Pique/SettingsView.swift Adds “Log” to appearance override options.
PiqueTests/FileFormatTests.swift Adds extension mapping tests for .log and case-insensitivity coverage.
PiqueTests/HighlightIntegrationTests.swift Adds integration tests for log highlighting heuristics and truncation notice behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Shared/SyntaxHighlighter.swift Outdated
Comment thread Shared/SyntaxHighlighter.swift Outdated
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds QuickLook preview support for log-like plaintext files and improves rendering performance for large previews by truncating input and optimizing HTML generation.

Changes:

  • Add .log file format support (.log, .out, .err) with heuristic, line-by-line tokenization and new token kinds/CSS.
  • Add preview truncation (~512KB) with an in-preview notice and apply truncation consistently across formats.
  • Optimize HTML rendering (escapeHTML single pass, renderTokens buffered construction) and expand test coverage for log highlighting + truncation.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Shared/SyntaxHighlighter.swift Adds .log format/tokenizer, truncation logic + notice insertion, and HTML rendering optimizations.
PiquePreview/Info.plist Registers a log UTI and declares log types/extensions supported by the QuickLook extension.
PiquePreview/PreviewProvider.swift Maps log extensions to the “Log” appearance group name.
Pique/Info.plist Declares the log UTI for the main app bundle.
Pique/ContentView.swift Adds a “Log” badge to the supported formats list.
Pique/SettingsView.swift Adds “Log” to appearance override settings.
PiqueTests/FileFormatTests.swift Tests extension-to-format mapping for log extensions (including case-insensitivity).
PiqueTests/HighlightIntegrationTests.swift Adds integration tests for log highlighting and truncation behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Shared/SyntaxHighlighter.swift
Comment thread Shared/SyntaxHighlighter.swift
neilmartin83 and others added 2 commits April 18, 2026 15:31
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Switch preview truncation from a UTF-8 byte limit to a character-based limit (previewCharLimit = 512_000), removing the UTF-8 index math and simplifying line counting. Truncation now slices by character index, appends truncation notices directly, and ensures special renderers (mobileconfig/json) receive truncated text and have the notice appended. Remove the insertTruncationNotice helper. Adjust log tokenization: simplify severity regex punctuation handling and treat 2xx HTTP status codes as .number instead of .logInfo. Update tests to match the new HTML expectations and remove several truncation-related test cases.
@neilmartin83 neilmartin83 requested a review from Copilot April 18, 2026 14:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds QuickLook preview support for log-like text files and improves rendering performance for large previews by truncating and optimizing token rendering/HTML escaping.

Changes:

  • Add .log/.out/.err file format detection and heuristic log tokenization + styling.
  • Improve performance via line-by-line log tokenization, faster escapeHTML, and buffered renderTokens.
  • Add preview truncation (~500KB) with an appended “Preview truncated … lines shown” notice, plus new/updated tests and UTI declarations.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Shared/SyntaxHighlighter.swift Adds log format + tokenizer, new token kinds/CSS, truncation, and rendering optimizations.
PiquePreview/Info.plist Declares log UTI and adds log types/extensions to QuickLook supported types.
PiquePreview/PreviewProvider.swift Maps log/out/err extensions to the “Log” appearance group name.
Pique/Info.plist Declares the log UTI in the main app.
Pique/ContentView.swift Adds “Log” to the supported-format badges shown in the app UI.
Pique/SettingsView.swift Adds “Log” to appearance override settings list.
PiqueTests/FileFormatTests.swift Tests extension→.log mapping and case-insensitivity for LOG.
PiqueTests/HighlightIntegrationTests.swift Adds integration tests for log highlighting and truncation notice behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Shared/SyntaxHighlighter.swift Outdated
Comment thread Shared/SyntaxHighlighter.swift Outdated
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds .log/.out/.err QuickLook preview support with heuristic highlighting and introduces rendering/truncation optimizations to improve performance on large files.

Changes:

  • Add FileFormat.log plus log-specific token kinds/CSS and a heuristic log tokenizer.
  • Add a global preview truncation mechanism (~512k chars) with a “Preview truncated…” notice.
  • Register log UTIs/extensions for the app + QuickLook extension, and add UI + test coverage for logs.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Shared/SyntaxHighlighter.swift Adds log format/tokenizer, new token kinds/CSS, truncation logic, and faster HTML rendering/escaping.
PiquePreview/Info.plist Declares the log UTI and adds log identifiers/extensions to QuickLook supported types.
PiquePreview/PreviewProvider.swift Maps .log/.out/.err to the “Log” format group name.
Pique/Info.plist Declares the log UTI for the main app.
Pique/ContentView.swift Adds a “Log” badge to the supported formats list.
Pique/SettingsView.swift Adds “Log” to appearance override settings.
PiqueTests/FileFormatTests.swift Adds extension-to-format tests for .log/.out/.err + case-insensitive mapping.
PiqueTests/HighlightIntegrationTests.swift Adds integration tests for log highlighting behaviors and truncation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Shared/SyntaxHighlighter.swift Outdated
Comment thread PiqueTests/HighlightIntegrationTests.swift Outdated
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds QuickLook preview support for log-like plain-text files and improves rendering performance for large inputs by optimizing HTML escaping/token rendering and introducing preview truncation.

Changes:

  • Add .log file format support (.log, .out, .err) with heuristic, line-by-line tokenization and dedicated severity/timestamp token kinds.
  • Introduce truncation (~512k chars) with a “Preview truncated …” notice, plus faster escapeHTML and renderTokens implementations.
  • Register log UTIs/extensions in app + preview targets and extend UI/tests to recognize and validate log highlighting.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Shared/SyntaxHighlighter.swift Adds .log format, heuristic tokenizer + CSS, truncation + perf optimizations in HTML rendering/escaping
PiquePreview/Info.plist Registers log UTI and wires it into QuickLook supported types/extensions
PiquePreview/PreviewProvider.swift Maps log extensions to a human-readable “Log” label
Pique/Info.plist Declares the log UTI for the main app
Pique/ContentView.swift Adds “Log” to the format badge list
Pique/SettingsView.swift Adds “Log” to appearance override options
PiqueTests/FileFormatTests.swift Tests extension mapping for .log/.out/.err and case-insensitivity
PiqueTests/HighlightIntegrationTests.swift Adds integration tests for log highlighting and truncation behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Shared/SyntaxHighlighter.swift
Comment thread Shared/SyntaxHighlighter.swift Outdated
Comment thread Shared/SyntaxHighlighter.swift Outdated
neilmartin83 and others added 2 commits April 18, 2026 15:57
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Replace verbose log token classes with short names (le,lw,li,ld,lt,ln,lk,ls,lv) and update tests accordingly. Remove preview truncation and its helpers (previewCharLimit, lineCount, truncationNotice, insertHTMLFragmentBeforeBodyClose) so highlight() operates on the full source and returns special renderers early for mobileconfig/JSON/markdown. Add fast and full log HTML renderers (renderLogHTML, renderLogHTMLFast, renderLogHTMLFull) that emit direct HTML via NSRegularExpression for better performance and reduced DOM size; adjust tokenizeLog comment. Optimize escapeHTML to work at the UTF-8 byte level and update CSS color rules to include the new short classes and muted variants. These changes improve performance and HTML output size for large logs and simplify the highlighting flow; tests were adjusted to match the new class names and truncated tests were removed.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds QuickLook preview/highlighting support for common log file extensions and introduces rendering-path optimizations intended to improve performance on large inputs.

Changes:

  • Add .log as a supported FileFormat (including .log, .out, .err) and map it through QuickLook + UI settings.
  • Implement heuristic log highlighting with a fast HTML renderer and new CSS classes for log tokens.
  • Add/extend tests to cover log extension mapping and highlighting behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Shared/SyntaxHighlighter.swift Adds .log format handling, heuristic log highlighter, and HTML rendering optimizations.
PiquePreview/Info.plist Declares/imports log UTI and registers extensions/content types for the QuickLook extension.
PiquePreview/PreviewProvider.swift Maps log extensions to the “Log” appearance group label.
Pique/Info.plist Declares/imports the log UTI for the main app bundle.
Pique/ContentView.swift Adds “Log” to the supported-format badges shown in the app UI.
Pique/SettingsView.swift Adds “Log” to appearance override settings.
PiqueTests/FileFormatTests.swift Adds extension mapping tests for .log/.out/.err and case insensitivity.
PiqueTests/HighlightIntegrationTests.swift Adds integration tests validating log highlighting output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1755 to +1780
var utf8 = Array(text.utf8)
var result: [UInt8] = []
result.reserveCapacity(utf8.count + utf8.count / 8)
var runStart = 0
for i in 0..<utf8.count {
let byte = utf8[i]
if byte == 0x26 || byte == 0x3C || byte == 0x3E || byte == 0x22 { // & < > "
// Flush preceding safe run
if i > runStart {
result.append(contentsOf: utf8[runStart..<i])
}
switch byte {
case 0x26: result.append(contentsOf: [0x26, 0x61, 0x6D, 0x70, 0x3B]) // &amp;
case 0x3C: result.append(contentsOf: [0x26, 0x6C, 0x74, 0x3B]) // &lt;
case 0x3E: result.append(contentsOf: [0x26, 0x67, 0x74, 0x3B]) // &gt;
case 0x22: result.append(contentsOf: [0x26, 0x71, 0x75, 0x6F, 0x74, 0x3B]) // &quot;
default: break
}
runStart = i + 1
}
}
// Flush remaining safe run
if runStart < utf8.count {
result.append(contentsOf: utf8[runStart...])
}
return String(bytes: result, encoding: .utf8) ?? text
Comment on lines +50 to +68
let body: String
switch format {
case .json: tokens = tokenizeJSON(source)
case .yaml: tokens = tokenizeYAML(source)
case .toml: tokens = tokenizeTOML(source)
case .xml, .mobileconfig: tokens = tokenizeXML(source)
case .shell: tokens = tokenizeShell(source)
case .powershell: tokens = tokenizePowerShell(source)
case .python: tokens = tokenizePython(source)
case .ruby: tokens = tokenizeRuby(source)
case .go: tokens = tokenizeGo(source)
case .rust: tokens = tokenizeRust(source)
case .javascript: tokens = tokenizeJavaScript(source)
case .json: body = renderTokens(tokenizeJSON(source))
case .yaml: body = renderTokens(tokenizeYAML(source))
case .toml: body = renderTokens(tokenizeTOML(source))
case .xml, .mobileconfig: body = renderTokens(tokenizeXML(source))
case .shell: body = renderTokens(tokenizeShell(source))
case .powershell: body = renderTokens(tokenizePowerShell(source))
case .python: body = renderTokens(tokenizePython(source))
case .ruby: body = renderTokens(tokenizeRuby(source))
case .go: body = renderTokens(tokenizeGo(source))
case .rust: body = renderTokens(tokenizeRust(source))
case .javascript: body = renderTokens(tokenizeJavaScript(source))
case .markdown: return renderMarkdown(source, dark: darkMode)
case .hcl: tokens = tokenizeHCL(source)
case .hcl: body = renderTokens(tokenizeHCL(source))
case .log: body = renderLogHTML(source)
}
return wrapHTML(renderTokens(tokens), dark: darkMode)

return wrapHTML(body, dark: darkMode)
Comment on lines +1124 to +1127
private static func tokenizeLog(_ src: String) -> [Token] {
// Thin wrapper for tests that inspect Token output.
// The live rendering path uses renderLogHTML() directly.
let regex = try! Regex(
Comment on lines +1261 to +1263
let allMatches = nsRegex.matches(in: src, range: NSRange(location: 0, length: totalLen))
var cursor = 0
for m in allMatches {
Comment on lines +1359 to +1361
let allMatches = nsRegex.matches(in: src, range: NSRange(location: 0, length: totalLen))
var cursor = 0
for m in allMatches {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants